﻿@model IEnumerable<PGE.Models.Visita>

@{
    ViewBag.Title = "Visitas";
}

<h2>Solicitações de agendamento de visitas</h2>

<p>
    @Html.ActionLink("Agendar Visita", "Create")
</p>
<table>
    <tr>
        <th>
            Cliente
        </th>
        <th>
            Status
        </th>
        <th>
            Data da Solicitação
        </th>
        <th>
            Data da Visita
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Cliente.Nome)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Status)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.DataHoraSolicitacao)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.DataHoraVisita)
        </td>
        <td>
            @if(item.Status == "SOLICITADA"){
                @Html.ActionLink("Confirmar Visita", "Confirm", new { id=item.ID }) <text>|</text>
            }            
            @Html.ActionLink("Detalhes", "Details", new { id=item.ID }) |
            @Html.ActionLink("Cancelar Visita", "Delete", new { id=item.ID })
        </td>
    </tr>   
}

</table>

<h2>Visitas Agendadas</h2>

<table>
    <tr>
        <th>
            Cliente
        </th>
        <th>
            Status
        </th>
        <th>
            Data da Solicitação
        </th>
        <th>
            Data da Visita
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    if (item.Status.Equals("agendada")){
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Cliente.Nome)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Status)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.DataHoraSolicitacao)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.DataHoraVisita)
        </td>
        <td>
            @Html.ActionLink("Detalhes", "Details", new { id=item.ID }) |
            @Html.ActionLink("Cancelar Visita", "Delete", new { id=item.ID })
        </td>
    </tr>
    }
   
}
</table>